<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="lib/jquery.js"></script>
<script type="text/javascript" src="lib/arbor.js"></script>
<script type="text/javascript" src="lib/graphics.js"></script>
<script type="text/javascript" src="lib/renderer.js"></script>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Visual Tweet Buzzer</title>
</head>

<body>
 <canvas id="viewport" width="800" height="800"></canvas>
<script type="text/javascript">

    $.ajax({
        type: "GET",
        url: "sam.xml",
        dataType: "xml",
        success: xmlParser
    });

function xmlParser(xml) {

	//alert("here");
	var username = $(xml).find("username").text();
	var sys = arbor.ParticleSystem();
	sys.parameters({ stiffness: 8000,
                repulsion: 2000,
                gravity: true,
                dt:0.015,
                friction: 0.8});
	sys.renderer = Renderer("#viewport") ;
	 var root = sys.addNode(username,{'color':'blue','shape':'dot','label':username,radius:3});
    $(xml).find("follows").each(function () {

    screenName = $(this).find("screenname").text();
	//alert(screenName);
	var id = $(this).find("topic").each(function(){
	id =  $(this).find("id").text();
	if(id=="3")
	{
	sentiment = $(this).find("sentiment").text();
	//alert(sentiment);
	 node = sys.addNode(screenName,{'color':sentiment,'shape':'dot','label':screenName,radius:3});
	  sys.addEdge(root,node);
	}
	});
});
	
}
</script>
</body>
</html>
